﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1.DesignerPatter.Test
{
    class StrategyMain
    {
        static void Main()
        {
            Context c = new Context(new ConcreteStrategyA());
            c.ContextInterface();
            Context c1 = new Context(new ConcreteStrategyB());
            c1.ContextInterface();
            Context c2 = new Context(new ConcreteStrategyC());
            c2.ContextInterface();
            Console.Read();
        }
    }

    public abstract class Strategy
    {                        
        public abstract void Algorithmlnterface();
    }

    class Context
    {
        Strategy stra;
        public Context(Strategy st)
        {
            stra = st;
        }

        public void ContextInterface()
        {
            stra.Algorithmlnterface();
        }
    }

    class ConcreteStrategyA : Strategy
    {
        public override void Algorithmlnterface()
        {
            Console.WriteLine("算法A");
        }
    }

    class ConcreteStrategyB : Strategy
    {
        public override void Algorithmlnterface()
        {
            Console.WriteLine("算法B");
        }
    }

    class ConcreteStrategyC : Strategy
    {
        public override void Algorithmlnterface()
        {
            Console.WriteLine("算法C");
        } 
    }
}
